<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

  <xi:include href="tb-master.html" />
<head>
	<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  	<title></title>
  	${tmpl_context.tabs()}
	<script type='text/javascript'>
	$(document).ready(function() { $('#navtabs').tabs(); });
	</script>

  	${tmpl_context.datatables()}
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
			$('#poststable').dataTable();
		} );
	</script>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
			$('#userstable').dataTable();
		} );
	</script>
  	${tmpl_context.googlemaps_js()}
</head>
<body>


<div id='navtabs'>
<ul>
<li><a href='#div_team'><span>Team</span></a></li>
<li><a href='#div_posts'><span>Posts</span></a></li>
<li><a href='#div_address'><span>Address</span></a></li>
<li><a href='#div_users'><span>Users</span></a></li>
</ul>

<div id="div_team">
<div id="post_content">
<table id="teaminfo">
<tbody>
<tr >
	<td style="width:60%" >
	<div >
		<h3 py:if="team.title">${team.title}
		<a onclick="return create('${root_url}/team/edit_page/${team.team_alias}', {modal: true});"
					href="">[Edit]</a>
		</h3>
		<h3 py:if="not team.title">No display name available
			<a onclick="return create('${root_url}/team/add_page/${team.team_alias}', {modal: true});"
				href="">[Add]</a></h3>
		<blockquote>
			<i py:if="team.description">${team.description}
			<a onclick="return create('${root_url}/team/edit_page/${team.team_alias}', {modal: true});"
					href="">[Edit]</a>
			</i>
			<i py:if="not team.description">No description available
				<a py:if="not team.page"
					onclick="return create('${root_url}/team/add_page/${team.team_alias}', {modal: true});"
					href="">[Add]</a>
				<a py:if="team.page"
					onclick="return create('${root_url}/team/edit_page/${team.team_alias}', {modal: true});"
					href="">[Add]</a>
			</i>
		</blockquote>
	</div>
	</td>
	<td>

        <div class="info" py:if="team.company" >
                <i py:if="team.address">${team.address.google_address}</i>
                <table>
                        <tr py:if="team.vat_code">
                                <th>P.IVA</th><td>${team.vat_code}</td>
                        </tr>
                        <tr py:if="team.phone">
                                <th>Phone</th><td>${team.phone}</td>
                        </tr>
                        <tr py:if="team.fax">
                                <th>Fax</th><td>${team.fax}</td>
                        </tr>
                        <tr py:if="team.mail">
                                <th>Email</th><td>${team.mail}</td>
                        </tr>
                </table>
        </div>
	</td>
	</tr>
	</tbody>
	</table>
</div>
	<div id="post_content">
		<div style="width:100%; text-align: right;">
			<a href="${root_url}/team/edit_page_content/${team.team_alias}">[Edit]</a>
		</div>
		<div py:if="team.xml_content">
			${XML(team.xml_content)}
		</div>
		<div py:if="not team.xml_content">
			No content available
		</div>
		<div style="width:100%; text-align: right;">
			<a href="${root_url}/team/edit_page_content/${team.team_alias}">[Edit]</a>
		</div>
	</div>
</div>

<div id="div_posts">

<div>
<table id="poststable">
<thead>
	<tr>
		<th>id</th>
		<th>title</th>
		<th>category</th>
		<th>date</th>
	</tr>
</thead>
<tbody>
<tr py:for="p in team.posts">
	<td>
		${p.post_id}
	</td>
	<td  >
		<a href="${root_url}/post/index/${team.team_alias}/${str(p.post_id)}"> ${p.post_title} </a>
	</td>
	<td>
		${p.post_category.category_label}
	</td>
	<td>
		${format_date(p.post_date, format='long', locale='it')}
	</td>
</tr>
</tbody>
</table>
</div>
</div>

<div id="div_address">
		<div id="post_map" class="ui-corner-all" >
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/team/edit_page_address/${team.team_alias}">[Edit]</a>
			</div>
			<h4 py:if="team.address">${team.page.post_address.google_address}</h4>
			<h4 py:if="not team.address">No address available</h4>
			<div id="map_canvas" style="height: 400px"></div>
		</div>
</div>


<div id="div_users">

	<div>
		<table id="userstable">
			<thead>
				<tr>
					<th>id</th>
					<th>Name Surname</th>
					<th>User</th>
					<th>Role</th>
				</tr>
			</thead>
			<tbody>
			<tr py:for="u in team.users">
				<td>
					${u.user_id}
				</td>
				<td  >
					<a href="#"> ${u.display_name} </a>
				</td>
				<td>
					${u.user_name}
				</td>
				<td>
					${team.role(u.user_id)}
				</td>
			</tr>
			</tbody>
		</table>
	</div>
</div>


	<script type="text/javascript">
	var allDialogs = [];

	function create(href, options) {
	options = $.extend({title: "Dialog"}, options || {});
	var dialog = new Boxy.load(href, options); /*new Boxy(content, options);*/
	allDialogs.push(dialog);
	return false;
	}
	</script>

</div>

  	<script py:if="team.address">
	google.load("maps", "2");


	// Call this function when the page has been loaded
	function initialize() {
	  var map_var =  {
		'div':'map_canvas',
		'zoom': 10,
		'lat': ${team.address.google_lat},
		'lng': ${team.address.google_lng},
	  };
	  var map = new google.maps.Map2(document.getElementById(map_var['div']));
	  map.setUIToDefault();
	  var point = new google.maps.LatLng(map_var['lat'], map_var['lng']);
	  map.setCenter(point, map_var['zoom']);
	  map.addOverlay(new google.maps.Marker(point));
	  //var Wikipedia = new google.maps.Layer("org.wikipedia.it");
	  //map.addOverlay(Wikipedia);
	  //var Panoramio = new google.maps.Layer("com.panoramio.all");
	  //map.addOverlay(Panoramio);
		}

	google.setOnLoadCallback(initialize);
  	</script>



</body>
</html>
